package org.jivesoftware.smackx.workgroup.settings;

import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smackx.workgroup.util.ModelUtil;
import org.xmlpull.v1.XmlPullParser;

public class OfflineSettings extends IQ
{
  public static final String ELEMENT_NAME = "offline-settings";
  public static final String NAMESPACE = "http://jivesoftware.com/protocol/workgroup";
  private String emailAddress;
  private String offlineText;
  private String redirectURL;
  private String subject;

  public String getChildElementXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<").append("offline-settings").append(" xmlns=");
    localStringBuilder.append('"');
    localStringBuilder.append("http://jivesoftware.com/protocol/workgroup");
    localStringBuilder.append('"');
    localStringBuilder.append("></").append("offline-settings").append("> ");
    return localStringBuilder.toString();
  }

  public String getEmailAddress()
  {
    String str;
    if (!(ModelUtil.hasLength(this.emailAddress)))
      str = "";
    while (true)
    {
      return str;
      str = this.emailAddress;
    }
  }

  public String getOfflineText()
  {
    String str;
    if (!(ModelUtil.hasLength(this.offlineText)))
      str = "";
    while (true)
    {
      return str;
      str = this.offlineText;
    }
  }

  public String getRedirectURL()
  {
    String str;
    if (!(ModelUtil.hasLength(this.redirectURL)))
      str = "";
    while (true)
    {
      return str;
      str = this.redirectURL;
    }
  }

  public String getSubject()
  {
    String str;
    if (!(ModelUtil.hasLength(this.subject)))
      str = "";
    while (true)
    {
      return str;
      str = this.subject;
    }
  }

  public boolean isConfigured()
  {
    int i;
    if ((ModelUtil.hasLength(getEmailAddress())) && (ModelUtil.hasLength(getSubject())) && (ModelUtil.hasLength(getOfflineText())))
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  public boolean redirects()
  {
    return ModelUtil.hasLength(getRedirectURL());
  }

  public void setEmailAddress(String paramString)
  {
    this.emailAddress = paramString;
  }

  public void setOfflineText(String paramString)
  {
    this.offlineText = paramString;
  }

  public void setRedirectURL(String paramString)
  {
    this.redirectURL = paramString;
  }

  public void setSubject(String paramString)
  {
    this.subject = paramString;
  }

  public static class InternalProvider
  implements IQProvider
  {
    public IQ parseIQ(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      if (paramXmlPullParser.getEventType() != 2)
        throw new IllegalStateException("Parser not in proper position, or bad XML.");
      OfflineSettings localOfflineSettings = new OfflineSettings();
      int i = 0;
      String str1 = null;
      String str2 = null;
      String str3 = null;
      String str4 = null;
      while (true)
      {
        int j;
        do
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  if (i != 0)
                  {
                    localOfflineSettings.setEmailAddress(str4);
                    localOfflineSettings.setRedirectURL(str1);
                    localOfflineSettings.setSubject(str2);
                    localOfflineSettings.setOfflineText(str3);
                    return localOfflineSettings;
                  }
                  j = paramXmlPullParser.next();
                  if ((j != 2) || (!("redirectPage".equals(paramXmlPullParser.getName()))))
                    break;
                  str1 = paramXmlPullParser.nextText();
                }
                if ((j != 2) || (!("subject".equals(paramXmlPullParser.getName()))))
                  break;
                str2 = paramXmlPullParser.nextText();
              }
              if ((j != 2) || (!("offlineText".equals(paramXmlPullParser.getName()))))
                break;
              str3 = paramXmlPullParser.nextText();
            }
            if ((j != 2) || (!("emailAddress".equals(paramXmlPullParser.getName()))))
              break;
            str4 = paramXmlPullParser.nextText();
          }
        while ((j != 3) || (!("offline-settings".equals(paramXmlPullParser.getName()))));
        i = 1;
      }
    }
  }
}